package com.xtoad.ecms.baseinfo.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.xtoad.ecms.baseinfo.model.User;

import java.util.List;

/**
 * 用户类Repository类
 *
 * @author xtoad
 * @date 2020/05/29
 */
@Repository
public interface IUserRepository extends JpaRepository<User, Long>, PagingAndSortingRepository<User, Long> {

    /**
     * 分页查询所有用户
     *
     * @param pageable
     * @return
     */
    @Override
    Page<User> findAll(Pageable pageable);

    /**
     * 根据姓名模糊查询用户
     *
     * @param name 姓名
     * @return 查询结果
     */
    List<User> findByNameContaining(final String name);

    /**
     * 根据登录名查询用户信息
     *
     * @param email 邮箱
     * @param phone 电话
     * @param loginNo 登录名
     * @return 查询结果
     */
    User findByEmailOrPhoneOrLoginNo(String email, String phone, String loginNo);
}
